package com.alibaba.dubbo.demo.consumer;

import java.io.Serializable;
import java.util.Map;

/**
 * rpc result
 * @author kingbo.ruan(aruan)
 * @time 2015-5-19  8:25:47
 */
public class Result implements Serializable{
	private static final long serialVersionUID = 1L;
	
	/**
	 * exception
	 */
	public final static int TYPE_EXCEPTION = 0;
	/**
	 * right result 
	 */
	public final static int TYPE_OBJECT = 1;
	/**
	 * null value
	 */
	public final static int TYPE_NULL = 2;
	
	
	/**
	 * unique request id
	 */
	private long id;
	/**
	 * value type
	 */
	private int type;
	/**
	 * result value
	 */
	private Object value;
	private Map<String, String> header;
	
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public Object getValue() {
		return value;
	}
	public void setValue(Object value) {
		this.value = value;
	}
	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	
	
	public Map<String, String> getHeader() {
		return header;
	}
	public void setHeader(Map<String, String> header) {
		this.header = header;
	}
	
	
	/**
	 * default constructor
	 */
	public Result() {
		super();
	}
	
	/**
	 * constructor 
	 * @param id-unique request id
	 * @param type-value type
	 * @param value-result value 
	 */
	public Result(long id, int type, Object value) {
		this(id, type, value, null);
	}
	
	/**
	 * constructor 
	 * @param id-unique request id
	 * @param type-value type
	 * @param value-result value 
	 */
	public Result(long id, int type, Object value, Map<String, String> header) {
		super();
		this.id = id;
		this.type = type;
		this.value = value;
		this.header = header;
	}
}
